<template>
  <div>
    <el-form
      ref="ruleForm"
      :model="ruleForm"
      :rules="rules"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="是否启用活动" prop="switch" label-width="300px;">
        <el-switch v-model="ruleForm.switch" @change="switchTag"></el-switch>
      </el-form-item>
      <el-form-item label="设置活动规则" prop="name" label-width="300px;">
        <el-button
          type="primary"
          plain
          :disabled="ruleForm.switch === true ? false : true"
          @click="created"
          >创建规则</el-button
        >
      </el-form-item>
      <el-form-item label="签到预览" prop="desc">
        <div
          style="cursor:pointer;z-index:100"
          @mouseenter="picture = true"
          @mouseout="picture = false"
        >
          <span>预览</span>
          <div v-if="picture">
            <img src="https://oss.ztwlxx.cn/sigin.png" alt="" width="150px;" />
          </div>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  name: "Siginav",
  data() {
    return {
      picture: false,
      sigin_open: 0,
      dataCode: [],
      ruleForm: {
        switch: false,
        name: "",
        desc: ""
      },
      rules: {
        switch: [
          { required: true, message: "请输入活动名称", trigger: "blur" }
        ],
        name: [
          { required: true, message: "请选择活动区域", trigger: "change" }
        ],
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }]
      }
    };
  },
  methods: {
    switchTag() {
      if (this.ruleForm.switch === true) {
        this.sigin_open = 1;
      }
    },
    created() {
      this.$emit("sigin", { siginA: "siginA", sigin_open: this.sigin_open });
    }
  }
};
</script>
